//
//  SecondHeadCollectionReusableView.m
//  ZiJinLian
//
//  Created by 🐛 on 2017/4/12.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "SecondHeadCollectionReusableView.h"

@implementation SecondHeadCollectionReusableView


- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        UIImageView*bgimag=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, MainW, 53)];
        //bgimag.image=[UIImage imageNamed:@"home_title_bg"];
        bgimag.backgroundColor=[UIColor whiteColor];
        [self addSubview:bgimag];
        NSString*str=@"热门去";
        CGSize size=[str sizeWithAttributes:@{NSFontAttributeName:FontAndStyle14 }];
        self.nameLabel=[[MYLabel alloc]initWithFrame:CGRectMake(bgimag.bsg_centerX-size.width/2, 10, size.width, 15)];
        self.nameLabel.text=@"热门区";
        self.nameLabel.textAlignment=1;
        self.nameLabel.textColor=button_Red_Color;
        self.nameLabel.backgroundColor=[UIColor clearColor];
        [bgimag addSubview:self.nameLabel];
        UIImageView*rightImg=[[UIImageView alloc]initWithFrame:CGRectMake(self.nameLabel.bsg_x-36, self.nameLabel.bsg_centerY-4, 26, 7)];
        rightImg.image=[UIImage imageNamed:@"img_title"];
        [bgimag addSubview:rightImg];
        UIImageView*leftImg=[[UIImageView alloc]initWithFrame:CGRectMake(self.nameLabel.bsg_right+10, self.nameLabel.bsg_centerY-4, 26, 7)];
        leftImg.image=[UIImage imageNamed:@"img_title"];
        [bgimag addSubview:leftImg];
        self.smallTitle=[[MYLabel alloc]initWithFrame:CGRectMake(0, self.nameLabel.bsg_bottom+7, MainW, 10)];
        self.smallTitle.font=[UIFont systemFontOfSize:10];
        self.smallTitle.textAlignment=1;
        self.smallTitle.text=@"八风吹不动,端坐紫金莲";
        self.smallTitle.textColor=Red_Color;
        [bgimag addSubview:self.smallTitle];
        UIImageView*bomm=[[UIImageView alloc]initWithFrame:CGRectMake(self.smallTitle.bsg_centerX-100, self.smallTitle.bsg_bottom+3, 200, 7)];
        bomm.image=[UIImage imageNamed:@"title_lines"];
        [bgimag addSubview:bomm];
        self.iconImag=[[UIImageView alloc]initWithFrame:CGRectMake(leftImg.bsg_right+20, 14, 18, 26)];
        self.iconImag.image=[UIImage imageNamed:@"title_img_hot"];
        [bgimag addSubview:self.iconImag];
        self.sectionBtn=[[UIButton alloc]initWithFrame:CGRectMake(MainW-130, 0,130, 50)];
        //self.sectionBtn.tag=800;
        [self.sectionBtn setBackgroundColor:[UIColor clearColor]];
        [self.sectionBtn addTarget:self action:@selector(sectionHeadClick:) forControlEvents:UIControlEventTouchUpInside];
        UIImageView *moreImg=[[UIImageView alloc]initWithFrame:CGRectMake(MainW-50, 18,40, 14)];
        moreImg.image=[UIImage imageNamed:@"more"];
        [self addSubview:moreImg];
        [self addSubview:self.sectionBtn];
        self.sectionScrollerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 53, MainW, MainW*0.4) delegate:self placeholderImage:[UIImage imageNamed:@"banner_bj"]];
    self.sectionScrollerView.bannerImageViewContentMode=UIViewContentModeScaleAspectFill;
        NSMutableArray * array1 =[NSMutableArray arrayWithObjects:@"fo",@"img_blank_monk",@"img_blank_monk",@"img_blank_monk",@"img_blank_monk",@"img_blank_monk",@"fo",@"fo",@"fo",@"fo", nil];
        
        //    for (scrollViewModel * model in self.scrollViewArray) {
        //        NSString * pic = [NSString stringWithFormat:@"%@%@",baseImgUrl,model.banner_img];
        //        [array addObject:pic];
        //    }
        
        //_cycleScrollerView.imageURLStringsGroup = array;  // 网络图片
        self.sectionScrollerView.localizationImageNamesGroup =array1 ; // 本地图片
        self.sectionScrollerView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        self.sectionScrollerView.autoScrollTimeInterval =3.;
        [self addSubview:self.sectionScrollerView];
    }
    return self;
}
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
    [_delegate cycleScrollView:cycleScrollView didSelectItemAtIndex:index];
}
-(void)sectionHeadClick:(UIButton *)sender{
    [_delegate sectionHeadClick:sender];
}
@end
